package fr.didier.template.sessions;



	import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.Composite;

	/**
	 * The superclass for paint tools that use click-drag-release motions to
	 * draw objects.
	 */
	public abstract class SessionLigne  {
		/**
		 * True if a click-drag is in progress
		 */
		private boolean dragInProgress = false;
		
		/**
		 * The position of the first click in a click-drag
		 */
		private Point anchorPosition = new Point(-1, -1);

		/**
		 * A temporary point
		 */
		private Point tempPosition = new Point(-1, -1);
	
		/**
		 * Activates the tool.
		 */
		public void beginSession() {
			
			anchorPosition.x = -1;
			dragInProgress = false;
			System.out.println("debut session"+anchorPosition.x);
		}
		
		/**
		 * Deactivates the tool.
	     */
		public void endSession() {
			
		}
		
		/**
		 * Resets the tool.
		 * Aborts any operation in progress.
		 */
		public void resetSession() {
	
			anchorPosition.x = -1;
			dragInProgress = false;
		}

		/**
		 * Handles a mouseDown event.
		 * 
		 * @param event the mouse event detail information
		 */
		public void mouseDown(MouseEvent event) {
			if (event.button != 1) return;
			if (dragInProgress) return; // spurious event
			dragInProgress = true;
			
			anchorPosition.x = event.x;
			anchorPosition.y = event.y;
		}

		/**
		 * Handles a mouseDoubleClick event.
		 * 
		 * @param event the mouse event detail information
		 */
		public void mouseDoubleClick(MouseEvent event) {
		}

		/**
		 * Handles a mouseUp event.
		 * 
		 * @param event the mouse event detail information
		 */
		public void mouseUp(MouseEvent event) {
			if (event.button != 1) {
				resetSession(); // abort if right or middle mouse button pressed
				return;
			}
			if (! dragInProgress) return; // spurious event
			dragInProgress = false;
			if (anchorPosition.x == -1) return; // spurious event
			

		}
		
		/**
		 * Handles a mouseMove event.
		 * 
		 * @param event the mouse event detail information
		 */
		public void mouseMove(MouseEvent event) {
			
		}
	

}
